package com.example.yemiantiaozhuan;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class CActivity extends Activity {
    private TextView t;
    private Button hui;
    private MediaPlayer player;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_c);
        t=(TextView)findViewById(R.id.t);
        hui=(Button)findViewById(R.id.hui);
        playAudio();
        hui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(CActivity.this,AActivity.class);
                startActivity(intent);}

        });
    }

    private void playAudio() {
        try {
            player = MediaPlayer.create(this, R.raw.sanqinggong);
            player.start();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }  catch (Exception e) {
            e.printStackTrace();
        }

    }
    protected void onDestroy() {
        super.onDestroy();
        if (player!=null){
            player.release();
            player=null;
        }
    }
}
